#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QTransform>

#include <QDirIterator>
//#include <QQuickWindow>

#include <qquickwindow.h>
#include <qthread.h>

int main(int argc, char *argv[]) {
//QThread::msleep(2000);
qputenv("QSG_RENDER_LOOP", "basic");
// 强制 OpenGL
//qputenv("QT_OPENGL", "desktop");
//qputenv("QSG_RHI_BACKEND", "opengl");

// 启用详细日志
qputenv("QSG_INFO", "1");
qputenv("QT_LOGGING_RULES", "qt.scenegraph.*=true");

QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);     // 设置为OpenGL


#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
    QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
    QGuiApplication app(argc, argv);

	app.setOrganizationName("smr");
	app.setOrganizationDomain("smr.best");
	app.setApplicationName("example-3");

	QQmlApplicationEngine engine;
	// Path to module.
	engine.addImportPath("qrc:/");

    const QUrl url(QStringLiteral("qrc:/main.qml"));
    QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
        &app, [url](QObject *obj, const QUrl &objUrl) {
            if (!obj && url == objUrl)
                QCoreApplication::exit(-1);
        }, Qt::QueuedConnection);
    engine.load("qrc:/main.qml");

    return app.exec();
}
